package com.my.mymafengwo.fragment;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.smallstrong.mafengwopro.R;
import com.my.mymafengwo.activity.MineLoginActivity;
import com.my.mymafengwo.activity.MineMessageActivity;
import com.my.mymafengwo.activity.MineSettingActivity;
import com.my.mymafengwo.activity.TravelNotesActivity;
import com.my.mymafengwo.base.BaseFragment;
import com.my.mymafengwo.utils.UrlUtils;

/**
 * ***********************************************
 * author:wgh
 * time:2015/12/3 22:18
 * copyright:
 * name: 我的
 * step:
 * ***********************************************
 */
public class MineFragment extends BaseFragment implements View.OnClickListener {
    private ImageView ivSetting, ivMessage;
    private LinearLayout llLogin;
    private RelativeLayout rlFengmi, rlDownload, rlFavorite, rlOrder, rlFavourable, rlAsset, rlActive;
    private TextView textView;

    @Override
    protected View initView() {
        View v = View.inflate(getActivity(), R.layout.fragment_mine, null);
        ivSetting = (ImageView) v.findViewById(R.id.iv_setting);
        ivMessage = (ImageView) v.findViewById(R.id.iv_message);
        llLogin = (LinearLayout) v.findViewById(R.id.ll_login);
        rlFengmi = (RelativeLayout) v.findViewById(R.id.rl_fengmi);
        rlDownload = (RelativeLayout) v.findViewById(R.id.rl_download);
        rlFavorite = (RelativeLayout) v.findViewById(R.id.rl_favorite);
        rlOrder = (RelativeLayout) v.findViewById(R.id.rl_order);
        rlFavourable = (RelativeLayout) v.findViewById(R.id.rl_favourable);
        rlAsset = (RelativeLayout) v.findViewById(R.id.rl_asset);
        rlActive = (RelativeLayout) v.findViewById(R.id.rl_active);
        textView = (TextView) v.findViewById(R.id.textView);
        return v;
    }

    @Override
    protected void initData() {
        ivMessage.setOnClickListener(this);
        ivSetting.setOnClickListener(this);
        llLogin.setOnClickListener(this);
        rlFengmi.setOnClickListener(this);
        rlDownload.setOnClickListener(this);
        rlFavorite.setOnClickListener(this);
        rlOrder.setOnClickListener(this);
        rlFavourable.setOnClickListener(this);
        rlAsset.setOnClickListener(this);
        rlActive.setOnClickListener(this);
        textView.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_setting:
                Intent intentSet = new Intent(mActivity, MineSettingActivity.class);
                startActivity(intentSet);
                break;
            case R.id.ll_login:
            case R.id.rl_favorite:
            case R.id.rl_order:
            case R.id.rl_favourable:
            case R.id.rl_asset:
            case R.id.rl_active:
            case R.id.textView:
            case R.id.rl_download:
                Intent intentLogin = new Intent(mActivity, MineLoginActivity.class);
                startActivity(intentLogin);
                break;
            case R.id.iv_message:
                Intent intentMessage = new Intent(mActivity, MineMessageActivity.class);
                startActivity(intentMessage);
                break;
            case R.id.rl_fengmi:
                Intent intentFengmi = new Intent(mActivity, TravelNotesActivity.class);
                intentFengmi.putExtra("url", UrlUtils.MINE_FENGMI_URL);
                startActivity(intentFengmi);
                break;
            default:
                break;
        }

    }
}
